﻿#region

using Cognex.VisionPro;
using Cognex.VisionPro.PMAlign;

using System;
using System.Collections.Generic;
using System.Windows.Forms;

#endregion

namespace 卡尺寻址
{
    public partial class 定位 : Form
    {
        public List<string> Results = new List<string>();
        private ICogImage iCogImage = null;

        public 定位()
        {
            InitializeComponent();
        }

        public 定位(ICogImage _img)
        {
            InitializeComponent();
            iCogImage = _img;
        }

        public Binding BindingBind { get; set; }

        private void 定位_FormClosed(object sender, FormClosedEventArgs e)
        {
        }

        private void 定位_FormClosing(object sender, FormClosingEventArgs e)          //结果发送给主界面
        {
            BindingBind.DataSourceNullValue = cogPMAlignEditV21.DataBindings;
            Class1.GetPMATrainData(cogPMAlignEditV21, out Results);
        }

        private void 定位_Load(object sender, EventArgs e)
        {
            cogPMAlignEditV21.Subject.InputImage = iCogImage;
            cogPMAlignEditV21.Subject.Pattern.IgnorePolarity = true;
            cogPMAlignEditV21.Subject.Pattern.TrainAlgorithm = CogPMAlignTrainAlgorithmConstants.PatQuick;
            cogPMAlignEditV21.Subject.Pattern.TrainMode = CogPMAlignTrainModeConstants.ShapeModelsWithImage;
            cogPMAlignEditV21.Subject.Pattern.TrainRegionMode = CogRegionModeConstants.PixelAlignedBoundingBoxAdjustMask;
            cogPMAlignEditV21.Subject.Pattern.TrainRegion = null;
            cogPMAlignEditV21.Subject.LastRunRecordDiagEnable = CogPMAlignLastRunRecordDiagConstants.All;
            cogPMAlignEditV21.Subject.RunParams.SaveMatchInfo = true;
            cogPMAlignEditV21.Subject.RunParams.OwnedFlexParams.SaveDeformationInfo = CogPMAlignFlexDeformationInfoConstants.TransformAndUnwarpData;
            cogPMAlignEditV21.Subject.RunParams.SaveMatchInfo = true;
            cogPMAlignEditV21.Subject.Pattern.TrainImage = iCogImage;

            cogPMAlignEditV21.Subject.Pattern = (CogPMAlignPattern)Class1.LoadVpp("PMA");
        }
    }
}